if(typeof w3c === "undefined") {w3c={}};
if(typeof w3c.CSSSelectors === "undefined") {w3c.CSSSelectors={}};

w3c.CSSSelectors = {
	querySelectorAll : function(cssSelector, element){
		element = element || this.element;
		return (this._internal_getElements(cssSelector,element)||[]);
	},
	
	_internal_getElements : function(cssSelector, element) {
		element = element || this.element;
        if (typeof Sly != "undefined") {
			return Sly.search(cssSelector, element);
		}
		else {
			throw new Error("w3c.CSSSelectors#_internal_getElements(), 'Sly' api is not defined.");
		}
    },
	
	querySelector : function(cssSelector, element){
		element = element || this.element;
		if(element.querySelector) {
			return element.querySelector(cssSelector);}
		else {
			return this._internal_getElements(cssSelector,element)[0];
		}
	}
}
